package cn.efunbox.afw.core.enums;

/**
 * Created by zhengjian on 2017/5/19.
 */
public enum ItemTypeEnum {
    COURSE("课程"),
    LESSON("课"),
    ENTITY_ITEM("实物"),
    OS_SERVICE("云服务"),
    CATEGORY("课程表分类"),
    SCHEDULE("课程表");

    private String desc;

    ItemTypeEnum(String desc) {
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    public static ItemTypeEnum getByName(String name) {
        if (name == null) {
            return null;
        }
        for (ItemTypeEnum itemTypeEnum : values()) {
            if (itemTypeEnum.name().equals(name)) {
                return itemTypeEnum;
            }
        }
        return null;
    }

    public static ItemTypeEnum getByNameWithDefault(String name) {
        if (name == null) {
            return COURSE;
        }
        for (ItemTypeEnum itemTypeEnum : values()) {
            if (itemTypeEnum.name().equals(name)) {
                return itemTypeEnum;
            }
        }
        return COURSE;
    }
}
